// /common/http.api.js

// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let userUrl = '/user'
let recordUrl = '/record'
let questionUrl = '/question'
let errorBookUrl = '/error-bobk'

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	
	let getUser = (params = {}) => vm.$u.get(userUrl + '/login',params)
	
	let updateUser = (params = {}) => vm.$u.get(userUrl + '/update',params)
	
	let getRecord = (params = {}) => vm.$u.get(recordUrl + '/getRecord',params)
	
	let updateOrderRecord = (params = {}) => vm.$u.get(recordUrl + '/updateOrderRecord',params) 
	
	let getOrderTk = (params = {}) => vm.$u.get(questionUrl + '/getOrderTk',params)
	
	let insertError = (params = {}) => vm.$u.get(errorBookUrl + '/insertError',params)
	
	let getExam =  (params = {}) => vm.$u.get(questionUrl + '/getExam',params)
	
	let getErrorQuestion = (params = {}) => vm.$u.get(errorBookUrl + '/getErrorQuestion',params)

	let delErrorQuestion = (params = {}) => vm.$u.get(errorBookUrl + '/del',params)
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {getUser,updateUser,getRecord,getOrderTk,updateOrderRecord,insertError,getExam,getErrorQuestion,delErrorQuestion};
}

export default {
	install
}